package com.fh.wanandroid.net;

import com.fh.wanandroid.base.BaseResponse;
import com.fh.wanandroid.ui.knowledge.KnowledgeDataList;
import com.fh.wanandroid.ui.mainpager.bean.BannerData;
import com.fh.wanandroid.ui.mainpager.bean.FeedArticleListData;
import com.fh.wanandroid.ui.navigation.bean.NavigationData;
import com.fh.wanandroid.ui.project.bean.ProjectData;
import com.fh.wanandroid.ui.wx.bean.WXAuthorListData;

import java.util.List;

import io.reactivex.Observable;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.Path;
import retrofit2.http.Query;

public interface ArticleApi {

    @GET("article/list/{num}/json")
    Observable<FeedArticleListData> getFeedArticleList(@Path("num") int num);


    /**
     * 知识体系
     * http://www.wanandroid.com/tree/json
     *
     * @return 知识体系数据
     */
    @GET("tree/json")
    Observable<BaseResponse<List<KnowledgeDataList>>> getKnowledgeData();


    /**
     * 知识体系下的文章
     *
     * @return 知识体系数据
     */
    @GET("article/list/{page}/json")
    Observable<FeedArticleListData> getKnowledgedArticleList(@Path("page") int page, @Query("cid") int cid);


    @GET("wxarticle/chapters/json")
    Observable<BaseResponse<List<WXAuthorListData>>> getWXAuthor();

    @GET("wxarticle/list/{id}/{page}/json")
    Observable<FeedArticleListData> getWxSumData(@Path("id") int id, @Path("page") int page);


    @GET("navi/json")
    Observable<NavigationData> getNavigation();

    @GET("project/tree/json")
    Observable<ProjectData> getProject();

    //    https://www.wanandroid.com/project/list/1/json?cid=294
    @GET("project/list/{page}/json")
    Observable<FeedArticleListData> getProjectArticleList(@Path("page") int page, @Query("cid") int cid);


    /**
     * 登陆
     * http://www.wanandroid.com/user/login
     *
     * @param username user name
     * @param password password
     * @return 登陆数据
     */

    @POST("user/login")
    @FormUrlEncoded
    Observable<FeedArticleListData> getLoginData(@Field("username") String username, @Field("password") String password);


    /**
     * https://www.wanandroid.com/user/register
     */
    @POST("user/register")
    @FormUrlEncoded
    Observable<FeedArticleListData> getRegisterData(@Field("username") String username, @Field("password") String password, @Field("repassword") String repassword);


    /**
     * 广告栏
     * http://www.wanandroid.com/banner/json
     *
     * @return 广告栏数据
     */
    @GET("banner/json")
    Observable<BannerData> getBannerData();

}
